public class StringBuffer extends Processor {
    int[] buffer;  // must be the first
    int slen;      // must be the second
    int length;
    static long x;

    public StringBuffer(int length) {
	buffer = new int[length];
	this.length = length;
	slen = 0;
    }

    public void clear() {
	slen = 0;
    }

    public int length() {
	return length;
    }

    public int strlen() {
	return slen;
    }

    public int charAt(int position) {
	return buffer[position];
    }

    // Implemented in Aino. Do not modify.
    public void append(String s) {
    }
    // ----------------------------------

    public void append(int i) {
	int d;
	d = i/100; // reminder in Math16.cLo
	buffer[slen++] = d + '0';
	i = Math16.cLo;
	d = i/10;
	buffer[slen++] = d + '0';
	buffer[slen++] = Math16.cLo + '0';
    }

    public void append(long ii) {
	for (x = 10000L; x > 0; x /= 10) {
	    ii = ii % x; // ii/x in Math16.bLo
	    buffer[slen++] = Math16.bLo + '0';
	}
    }

    public void append(char c) {
	buffer[slen++] = (int)c;
    }
}
